<template>
  <div class="dynic">
    <div class="no-data fx-c bg-w" v-if="!noData" style="padding: 4rem 2rem">
      {{ word }}
    </div>
    <Loading v-if="!arr.length && noData"></Loading>
    <template v-else>
      <template v-for="(item, i) in arr">
        <DArt v-if="item.code == 1" :item="item" :key="i"></DArt>
        <DArt v-else-if="item.code === 5" :key="i" :item="item"></DArt>
        <FocusUser v-else :user="item" :key="i"></FocusUser>
      </template>
    </template>
  </div>
</template>

<script>
import DArt from "@/components/user/userDetail/userDynic/navMenu/Dynic/DArt";
import FocusUser from "@/components/user/userDetail/userDynic/navMenu/Dynic/FocusUser";
import Loading from "@/components/common/Loading";
import { getUserDetail } from "@/api/user";
import { normlizeUseDynic, getSessionStorage, parse } from "@/utils/utils";
export default {
  name: "Dynic",
  components: {
    DArt,
    FocusUser,
    Loading,
  },
  data() {
    return {
      arr: {},
      word: "用户还没有动态哦",
      noData: true,
    };
  },
  async created() {
    const i = getSessionStorage("cid");
    let id;
    if (i) {
      id = parse(i).id;
    }
    const res = await getUserDetail(id);
    if (res.code == 1) {
      const arr = await normlizeUseDynic(res.data.dynic, res.data);
      this.arr = arr;
      if (!this.arr.length) this.noData = false;
    }
  },
};
</script>

<style lang="scss" scoped>
</style>